#!/bin/bash

if [ "$SOURCE_BRANCH" == "master" ] && [[ "$IMAGE_NAME" == *:master ]]; then
    GIT_REPO="keycloak/keycloak"
    GIT_BRANCH="master"
elif [[ "$IMAGE_NAME" == *:nightly-* ]]; then
    GIT_REPO="keycloak/keycloak"
    GIT_BRANCH=`echo $IMAGE_NAME | cut -d ':' -f 2 | sed 's|nightly-||'`
fi

docker build --build-arg GIT_REPO=$GIT_REPO --build-arg GIT_BRANCH=$GIT_BRANCH -t $IMAGE_NAME .
